1 #ifndef TEACHER_H
2 #define TEACHER_H
3
4 #include<fstream>
5 #include
"student.h"
6 #include<iostream>

7
8 using
namespace std;
9 class
teacher
10 {
11   
char name[20];
12   
char subject[20];
13   
int subcode;
14   
int teacherid;
15 public
:
16   
void input()
17   {
18     cout<<
"\nEnter the name of teacher: ";
19     cin>>name;
20     cout<<
"Enter teacher id number: ";
21     cin>>teacherid;
22     cout<<
"\nEnter subject name: ";
23     cin>>subject;
24     cout<<
"\nEnter subject code (1-5): ";
25     cin>>subcode;
26     subcode = subcode-
1;
27   }
28
29   
int idcompare(int id)
30   {
31     
if(teacherid == id)
32       
return 1;
33
34       
else
35         
return 0;
36   }
37
38   
void display()
39   {
40     cout<<
"\nName of teacher: ";
41     puts(name);
42     cout<<
"Teacher id number: "<<teacherid;
43     cout<<
"\nSubject name: ";
44     puts(subject);
45     cout<<
"Subject code: "<<subcode;
46   }
47
48   
void updateMarks()
49   {
50     fstream fio(
"student.dat", ios::in|ios::out|ios::binary);
51     
int count = 0, marks;
52     student S;
53     
long pos;
54
55     cout<<
"\n\nUpload marks of all students for the subject "<<subject;
56
57     pos = fio.tellg();
58
59     
while(fio.read((char*)&S,sizeof(S)))
60     {
61       cout<<
"\nEnter marks of student roll number "<<S.getroll()<<" : ";
62       cin>>marks;
63       S.entermarks(subcode, marks);
64       fio.seekp(pos);
65       fio.write((
char*)&S,sizeof(S));
66       count++;
67       pos = fio.tellg();
68     }
69
70     
if(count == 0)
71       cout<<
"\n\nNo students enrolled";
72
73     
else
74       cout<<
"\nAll student marks have been uploaded successfully";
75
76       fio.close();
77   }
78 };
79
80 #endif


Gõ tìm kiếm nhanh...